﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.Departments" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Departments Page" xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <Grid x:Name="LayoutRoot">
        <ScrollViewer BorderThickness="0"  VerticalScrollBarVisibility="Auto" Padding="12,0,12,0" Margin="-12">
            <StackPanel Margin="0,12,0,12" Orientation="Vertical" >
                <StackPanel Orientation="Horizontal" 
                  HorizontalAlignment="Stretch" 
                  Margin="0,16,0,0">
                    <HyperlinkButton x:Name="ImgNewDepartment" Margin="4" Height="25" Width="21"  Grid.RowSpan="3" Click="ImgNewDepartmen_Click">
                        <HyperlinkButton.Background>
                            <ImageBrush ImageSource="/LEEAAttendanceControl;component/Images/create.png" />
                        </HyperlinkButton.Background>
                    </HyperlinkButton>
                    <StackPanel.Background>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFF6F7F8" Offset="0.372" />
                            <GradientStop Color="#00807F76" Offset="1" />
                        </LinearGradientBrush>
                    </StackPanel.Background>
                </StackPanel>


                <riaControls:DomainDataSource  AutoLoad="True" Height="0" QueryName="GetDepartmentsWithCompany"  Name="DepartmentDataSource" PageSize="5" LoadSize="20" Width="0" LoadingData="DepartmentDataSource_LoadingData_1">
                    <riaControls:DomainDataSource.DomainContext>
                        <my:LEEAContext />
                    </riaControls:DomainDataSource.DomainContext>
                </riaControls:DomainDataSource>
                <sdk:DataGrid AutoGenerateColumns="False" HorizontalAlignment="Stretch" ItemsSource="{Binding ElementName=DepartmentDataSource, Path=Data}"  Name="GRDDepartment" RowDetailsVisibilityMode="VisibleWhenSelected" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn x:Name="companyNameColumn" Binding="{Binding Path=Company.CompanyName}" Header="Company ID" Width="SizeToHeader" />
                        <sdk:DataGridTextColumn x:Name="departmentCodeColumn" Binding="{Binding Path=DepartmentCode, Mode=OneWay}" Header="Department Code" IsReadOnly="True" Width="SizeToHeader" />
                        <sdk:DataGridTextColumn x:Name="departmentNameColumn" Binding="{Binding Path=DepartmentName}" Header="Department Name" Width="SizeToHeader" />
                        <sdk:DataGridTemplateColumn CanUserReorder="True"  CanUserResize="True" CanUserSort="True" Header="Edit" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <HyperlinkButton x:Name="LnkEditDepartment" Margin="4" Height="25" Width="21"  Grid.RowSpan="3" Click="LnkEditDepartment_Click">
                                        <HyperlinkButton.Background>
                                            <ImageBrush ImageSource="/LEEAAttendanceControl;component/Images/edit.png" />
                                        </HyperlinkButton.Background>
                                    </HyperlinkButton>

                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>

                        <sdk:DataGridTemplateColumn CanUserReorder="True"  CanUserResize="True" CanUserSort="True" Header="Edit" Width="Auto" >
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate >
                                    <HyperlinkButton x:Name="LnkDeleteDepartment" Margin="4" Height="25" Width="21"  Grid.RowSpan="3" Click="LnkDeleteDepartment_Click">
                                        <HyperlinkButton.Background>
                                            <ImageBrush ImageSource="/LEEAAttendanceControl;component/Images/delete.png" />
                                        </HyperlinkButton.Background>
                                    </HyperlinkButton>

                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>


                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
                <sdk:DataPager  Name="CompanyPager" PageSize="5" Source="{Binding Data, ElementName=DepartmentDataSource}" />
            </StackPanel>
        </ScrollViewer>
    </Grid>
</navigation:Page>
